package com.dream.vo.order;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.constraints.NotBlank;

import com.dream.model.order.OrderCustomerProduct;
import com.dream.utils.date.DateParseUtils;
import com.dream.vo.base.FirstGroup;

public class CustomerProductVO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1589637623797728803L;
	
	private String id;
	
	private Long customerId;
	
	private String productId;
	
	@NotBlank(message = "err0001",groups = {FirstGroup.class})
	private String productName;
	
	@NotBlank(message = "err0001",groups = {FirstGroup.class})
	private String firstCat;
	
	@NotBlank(message = "err0001",groups = {FirstGroup.class})
	private String secondCat;
	
	@NotBlank(message = "err0001",groups = {FirstGroup.class})
	private String purchaseDate;
	
	private String purchasePrice;
	
	private String recepitNo;
	
	private String barCode;
	
	private String mandatoryNo;
	
	private String salesShop;
	
	private String salesContact;
	
	private String productComment;
	
	
	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	public Long getCustomerId() {
		return customerId;
	}

	public void setCustomerId(Long customerId) {
		this.customerId = customerId;
	}

	public String getPurchaseDate() {
		return purchaseDate;
	}

	public void setPurchaseDate(String purchaseDate) {
		this.purchaseDate = purchaseDate;
	}
	
	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getFirstCat() {
		return firstCat;
	}

	public void setFirstCat(String firstCat) {
		this.firstCat = firstCat;
	}

	public String getSecondCat() {
		return secondCat;
	}

	public void setSecondCat(String secondCat) {
		this.secondCat = secondCat;
	}

	public String getPurchasePrice() {
		return purchasePrice;
	}

	public void setPurchasePrice(String purchasePrice) {
		this.purchasePrice = purchasePrice;
	}

	public String getRecepitNo() {
		return recepitNo;
	}

	public void setRecepitNo(String recepitNo) {
		this.recepitNo = recepitNo;
	}

	public String getBarCode() {
		return barCode;
	}

	public void setBarCode(String barCode) {
		this.barCode = barCode;
	}

	public String getMandatoryNo() {
		return mandatoryNo;
	}

	public void setMandatoryNo(String mandatoryNo) {
		this.mandatoryNo = mandatoryNo;
	}

	public String getSalesShop() {
		return salesShop;
	}

	public void setSalesShop(String salesShop) {
		this.salesShop = salesShop;
	}

	public String getSalesContact() {
		return salesContact;
	}

	public void setSalesContact(String salesContact) {
		this.salesContact = salesContact;
	}

	public String getProductComment() {
		return productComment;
	}

	public void setProductComment(String productComment) {
		this.productComment = productComment;
	}
	
	public void populate(OrderCustomerProduct product){
		
		if(product == null) { return ;}
		
		
		product.setProductId(productId);
		product.setBarCode(barCode);
		product.setPurchaseDate(DateParseUtils.parseDateWithNull(purchaseDate));
		
		if(id == null){
			product.setComments(productComment);
			product.setMandatoryNo(mandatoryNo);
			if(StringUtils.isNotBlank(purchasePrice)){
				product.setPurchasePrice(Float.parseFloat(purchasePrice));
			}
			product.setRecepitNo(recepitNo);
			product.setSalesShop(salesShop);
			product.setSalesContact(salesContact);
			product.setCustomerId(customerId);
		}
		
	}
	
}
